@echo off
REM IPSet设置 win7/10版
REM JianPF 22:36 2022/9/2
REM 此文件是ASIN编码(旧版)
REM ipconfig >ipconfig.txt
REM findstr "网适配器" ipconfig.txt >ipconfigName.txt
REM del ipconfigNames.txt
REM for /f "tokens=2 delims=: "  %%i in (ipconfigName.txt) do echo %%i >>ipconfigNames.txt
REM ipconfig
REM echo -----
REM echo 请选择设备:
REM more ipconfigNames.txt
REM pause
REM 显示当前配置
REM 以上为选择设备名,未开放完成,可以删除


REM 程序开始
echo -----
echo %date% %time%
echo -----
:Menu
ipconfig /all
echo -----
echo %date% %time%
echo -----
REM 手动选择设备,可以在:控制面板\网络和 Internet\网络连接 修改网卡名称
set ieName="以太网"

REM 设置第一组IP地址,掩码,网关路由,域名DNS
set ipa1=192.168.8.80
set ipm1=255.255.255.0
set ipg1=192.168.8.1
set idns1=8.8.4.4

REM 设置第二组IP地址,掩码,网关路由,域名DNS
set ipa2=192.168.1.80
set ipm2=255.255.255.0
set ipg2=192.168.1.1
set idns2=8.8.4.4

REM 设置第三组IP地址,掩码,网关路由,域名DNS
set ipa3=192.168.2.80
set ipm3=255.255.255.0
set ipg3=192.168.2.1
set idns3=8.8.4.4

REM 显示菜单
echo [0] DHCP动态获取IP地址
echo [1] 手动IP地址
echo [2] 手动IP地址
echo [3] 手动IP地址 

set /p ipsetdo="请选择:[0-3]"
REM set ipsetdo=0

if %ipsetdo%==0 (call :ipa0)
if %ipsetdo%==1 (call :ipa1)
if %ipsetdo%==2 (call :ipa2)
if %ipsetdo%==3 (call :ipa3)

goto :Menu

REM DHCP处理过程
:ipa0
color a
netsh interface ip set address name=%ieName% source=dhcp
netsh interface ip set dns name=%ieName% source=dhcp
exit /b 0

REM 第一组处理过程
:ipa1
color b
netsh interface ip set address name=%ieName% static %ipa1% %ipm1% %ipg1% 1
netsh interface ip set dns name=%ieName% static %idns1% primary
exit /b 0

REM 第二组处理过程
:ipa2
color c
netsh interface ip set address name=%ieName% static %ipa2% %ipm2% %ipg2% 1
netsh interface ip set dns name=%ieName% static %idns2% primary
exit /b 0

REM 第三组处理过程
:ipa3
color e
netsh interface ip set address name=%ieName% static %ipa3% %ipm3% %ipg3% 1
netsh interface ip set dns name=%ieName% static %idns3% primary
exit /b 0



